CAST(... AS CHAR/VARCHAR)
can be a source of incompatibilities between database versions: the behavior of CAST
may not be
the same depending on the version of the database system. Such incompatibilities can cause unexpected output from applications that CAST
decimal data to CHAR
or VARCHAR
, it’s therefore best to avoid using CAST(... AS CHAR/VARCHAR)
.
Noncompliant code example
DELETE product
WHERE CAST(status_code AS CHAR(2)) = '42' -- Noncompliant